﻿/*
    This file is part of ndoctor-statistics.

    ndoctor-statistics is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ndoctor-statistics is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ndoctor-statistics.  If not, see <http://www.gnu.org/licenses/>.
*/
namespace Probel.NDoctor.Statistics.Mappings
{
    using FluentNHibernate.Automapping;
    using FluentNHibernate.Conventions.Helpers;

    using Probel.NDoctor.Statistics.Domain;

    internal class MyAutoPersistenceModel
    {
        #region Fields

        private readonly AutoPersistenceModel AutoPersistenceModel;

        #endregion Fields

        #region Constructors

        public MyAutoPersistenceModel()
        {
            this.AutoPersistenceModel = AutoMap.AssemblyOf<Entity>(new CustomAutomappingConfiguration())
                    .IgnoreBase<Entity>()
                    .Conventions.Add(DefaultCascade.SaveUpdate()
                                   , DynamicUpdate.AlwaysTrue()
                                   , DynamicInsert.AlwaysTrue()
                                   , LazyLoad.Always());
        }

        #endregion Constructors

        #region Methods

        /// <summary>
        /// Performs an implicit conversion from <see cref="Probel.NDoctor.Domain.DAL.Cfg.MyAutoPersistenceModel"/> to <see cref="?"/>.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>
        /// The result of the conversion.
        /// </returns>
        public static implicit operator AutoPersistenceModel(MyAutoPersistenceModel model)
        {
            return model.AutoPersistenceModel;
        }

        #endregion Methods
    }
}